package dataMapper;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import dataEntity.PreventiveServicesUse;

public class PreventiveServicesUseMapper {
	public static Map<String,Map<String,PreventiveServicesUse>> process(BufferedReader br){
		Map<String,Map<String,PreventiveServicesUse>> map = new HashMap<String,Map<String,PreventiveServicesUse>> ();
		try {
			br.readLine();
			while(br.ready()){
				PreventiveServicesUse object = buildObject(br.readLine());

				Map<String,PreventiveServicesUse> stateMap = map.get(object.getCHSI_State_Abbr());
				if(stateMap == null) stateMap = new HashMap<String,PreventiveServicesUse>();
				stateMap.put(object.getCHSI_County_Name(), object);
				map.put(object.getCHSI_State_Abbr(), stateMap);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return map;
	}
	
	public static  PreventiveServicesUse buildObject(String inLine){
		String[] line = inLine.split(",");
		PreventiveServicesUse object = new PreventiveServicesUse();
		
		object.setState_FIPS_Code(line[0]);
		object.setCounty_FIPS_Code(line[1]);
		object.setCHSI_County_Name(line[2]);
		object.setCHSI_State_Name(line[3]);
		object.setCHSI_State_Abbr(line[4]);
		object.setStrata_ID_Number(line[5]);
		object.setFluB_Rpt(line[6]);
		object.setFluB_Ind(line[7]);
		object.setFluB_Exp(line[8]);
		object.setHepA_Rpt(line[9]);
		object.setHepA_Ind(line[10]);
		object.setHepA_Exp(line[11]);
		object.setHepB_Rpt(line[12]);
		object.setHepB_Ind(line[13]);
		object.setHepB_Exp(line[14]);
		object.setMeas_Rpt(line[15]);
		object.setMeas_Ind(line[16]);
		object.setMeas_Exp(line[17]);
		object.setPert_Rpt(line[18]);
		object.setPert_Ind(line[19]);
		object.setPert_Exp(line[20]);
		object.setCRS_Rpt(line[21]);
		object.setCRS_Ind(line[22]);
		object.setCRS_Exp(line[23]);
		object.setSyphilis_Rpt(line[24]);
		object.setSyphilis_Ind(line[25]);
		object.setSyphilis_Exp(line[26]);
		object.setID_Time_Span(line[27]);
		object.setPap_Smear(line[28]);
		object.setCI_Min_Pap_Smear(line[29]);
		object.setCI_Max_Pap_Smear(line[30]);
		object.setMammogram(line[31]);
		object.setCI_Min_Mammogram(line[32]);
		object.setCI_Max_Mammogram(line[33]);
		object.setProctoscopy(line[34]);
		object.setCI_Min_Proctoscopy(line[35]);
		object.setCI_Max_Proctoscopy(line[36]);
		object.setPneumo_Vax(line[37]);
		object.setCI_Min_Pneumo_Vax(line[38]);
		object.setCI_Max_Pneumo_Vax(line[39]);
		object.setFlu_Vac(line[40]);
		object.setCI_Min_Flu_Vac(line[41]);
		object.setCI_Max_Flu_Vac(line[42]);

		return object;
	}
}
